<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="/layui/css/layui.css">
  <link rel="stylesheet" href="/css/custom.form.css">
</head>
<style>

    .layui-form-label {
        width: 150px;
    }
     .layui-input-block {
         margin-left: 160px;
    }
    .layui-col-sm {
         margin-left: 160px;
    }

</style>
<body>
<div class="panel panel-default operation" >
  <div class="panel-heading title"></div>
    <div class="layui-card-body">
        <form class="layui-form " action="" lay-filter="info" style="width: 700px;margin-top: 10px">
            <input name="id" hidden/>
            <div class="layui-form-item">
                <label class="layui-form-label">领取频率限制</label>
                <div class="layui-input-block">
                    <input type="lqxz" name="lqxz" placeholder="请输入领取频率限制" autocomplete="off" class="layui-input">
                </div>
                <small class="layui-col-sm">每天领取限制 0代表不限制(修改后即时生效)</small>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">未跟进流公海限制</label>
                <div class="layui-input-block">
                    <input type="wgjhl" name="wgjhl" placeholder="请输入未跟进流公海限制天数" autocomplete="off" class="layui-input">
                </div>
                <small class="layui-col-sm">超过限制天数未跟进流公海 0代表不限制(修改后次日生效)</small>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">未成交流公海限制</label>
                <div class="layui-input-block">
                    <input type="wcjhl" name="wcjhl" placeholder="请输入未成交流公海限制天数" autocomplete="off" class="layui-input">
                </div>
                <small class="layui-col-sm">超过限制天数未成交流公海 0代表不限制(修改后次日生效)</small>
            </div>
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">领取数量上限</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input type="lqsz" name="lqsz" placeholder="请输入领取数量上限" autocomplete="off" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
            <div class="layui-form-item">
                <label class="layui-form-label">是否开启电话隐私权限</label>
                <div class="layui-input-block">
                    <select name="isyc">
                        <option value="0">否</option>
                        <option value="1">是</option>
                    </select>
                </div>
            </div>
            <!--        <div class="layui-form-item">-->
            <!--      <label class="layui-form-label">所属公司</label>-->
            <!--      <div class="layui-input-block">-->
            <!--        <input type="ssgs" name="ssgs" placeholder="请输入所属公司" autocomplete="off" class="layui-input">-->
            <!--      </div>-->
            <!--    </div>-->
            <!--        <div class="layui-form-item">-->
            <!--      <label class="layui-form-label">备注</label>-->
            <!--      <div class="layui-input-block">-->
            <!--        <input type="bz" name="bz" placeholder="请输入备注" autocomplete="off" class="layui-input">-->
            <!--      </div>-->
            <!--    </div>-->
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="submit">保存</button>
<!--                    <button  class="layui-btn layui-btn-primary" id="btn_cancel">返回</button>-->
                </div>
            </div>
        </form>

    </div>
</div>

<div class="table_div" hidden>
  <div id="searchParam"  shiro:hasPermission="tGzsz:list">
    <div class="layui-form-item">
      <div class="layui-input-inline">
        <input type="text" id="key" class="layui-input"  autocomplete="off" placeholder="请输入">
      </div>

      <div class="layui-input-inline ">
        <button class="layui-btn" onclick="search()"  id="search">查询</button>
        <!--        <button class="layui-btn"   id="export">导出全部</button>-->
      </div>
    </div>

  </div>
  <table class="layui-table" id="showTable" lay-filter="showTable" ></table>
</div>
<script type="text/html" id="toolbar">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm" lay-event="add"  shiro:hasPermission="tGzsz:add">添加</button>
    <button class="layui-btn layui-btn-sm" lay-event="batchDeleted" shiro:hasPermission="tGzsz:delete">删除</button>
  </div>
</script>
<script type="text/html" id="tool">
  <a class="layui-btn layui-btn-xs" lay-event="edit" shiro:hasPermission="tGzsz:update">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" shiro:hasPermission="tGzsz:delete">删除</a>
</script>

</body>
</html>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script>
  //获取token
  var token = CoreUtil.getData("access_token");
  //地址栏转义token中的#号
  var tokenQuery = token.replace("#", "%23");
  var tableIns1;
  var table = layui.table;
  var form = layui.form;
  var layer = layui.layer;
  var $ = jQuery = layui.jquery;
  var laydate = layui.laydate;
  info();
  layui.use(['table', 'layer', 'laydate'], function () {
    //监听保存
    form.on('submit(submit)', function(data){
      if(data.field.id===undefined || data.field.id===null || data.field.id===""){
        CoreUtil.sendPost("/tGzsz/add",data.field,function (res) {
            var code = res.code;
            if (code == 0){
                layer.msg(res.msg);
            }
            info();
        });
      }else {
        CoreUtil.sendPut("/tGzsz/update",data.field,function (res) {
            var code = res.code;
            if (code == 0){
                layer.msg(res.msg);
            }
            info();
        });
      }
      return false;
    });

  });
  function info(){
      CoreUtil.sendGet("/tGzsz/info",null,function (res) {
          var data = res.data;
          if (!!data){
              //给表单赋值
              form.val("info", {
                  id: data.id,
                  lqxz: data.lqxz,
                  wgjhl: data.wgjhl,
                  wcjhl: data.wcjhl,
                  isyc: data.isyc,
              });
          } else {
              //给表单赋值
              form.val("info", {
                  lqxz: 0,
                  wgjhl: 0,
                  wcjhl: 0,
                  isyc: 0,
              });
          }
      });
  }

</script>